﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel;
using Common.Services.ServiceContracts;


namespace ProductsGUI
{

    public class ServiceManager
    {
        private static ServiceManager m_Instance;
        public static ServiceManager Instance
        {
            get
            {
                if (m_Instance == null)
                {
                    m_Instance = new ServiceManager();
                }

                return m_Instance;
            }
        }

        private T GetChannel<T>(string serviceName)
        {
            try
            {
                ChannelFactory<T> factory = new ChannelFactory<T>(serviceName);
                T res = factory.CreateChannel();
                return res;
            }
            catch (Exception)
            {
                throw;
            }
        }

        public IServiceTest GilService
        {
            get
            {
                return GetChannel<IServiceTest>("BasicHttpBinding_IServiceTest");
            }
        }

        public IGlobalServices GlobalServices
        {
            get
            {
                return GetChannel<IGlobalServices>("BasicHttpBinding_IGlobalServices");
            }
        }



        
       
    }  
}